package com.example.dllo.my36kr.find.findshare;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.example.dllo.my36kr.R;
import com.example.dllo.my36kr.find.findpeople.PeopleAdapter;
import com.example.dllo.my36kr.find.findpeople.PeopleBean;
import com.example.dllo.my36kr.news.project.ProjectAdapter;
import com.example.dllo.my36kr.news.project.ProjectBean;
import com.example.dllo.my36kr.tools.BaseAty;
import com.example.dllo.my36kr.tools.NetTool;
import com.example.dllo.my36kr.tools.StaticUrl;

/**
 * Created by dllo on 16/8/26.
 */
public class FindShareAty extends BaseAty {

    private TextView showTv;
    private Button back;
    private ListView listView;
    private ProjectAdapter adapter;
    private PeopleAdapter peopleAdapter;

    @Override
    protected int setLayout() {
        return R.layout.aty_findshare;
    }

    @Override
    protected void initView() {
        showTv = bindView(R.id.tv_aty_findshare_show);//标题的TextView
        back = bindView(R.id.bnt_aty_findshare_back);//返回键
        listView = bindView(R.id.lv_aty_findshare);
        peopleAdapter = new PeopleAdapter(getApplicationContext());
        adapter = new ProjectAdapter(getApplicationContext());

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


    }

    @Override
    protected void initData() {
        Intent intent = getIntent();//Intent 接收值
        String find = intent.getStringExtra("find");
        if ((StaticUrl.NEWS_RESEARCH_URL).equals(find)){
            mNetTool.getNetData(find, ProjectBean.class, new NetTool.NetListener<ProjectBean>() {//36氪研究院
                @Override
                public void onSuccess(ProjectBean projectBean) {
                    adapter.setList(projectBean);
                    listView.setAdapter(adapter);

                }
                @Override
                public void onError(String errorMsg) {
                }
            });
            showTv.setText("36氪研究院");
        }else {
            mNetTool.getNetData(find, PeopleBean.class, new NetTool.NetListener<PeopleBean>() {
                @Override
                public void onSuccess(PeopleBean peopleBean) {
                    peopleAdapter.setBean(peopleBean);
                    listView.setAdapter(peopleAdapter);
                }
                @Override
                public void onError(String errorMsg) {

                }
            });
            showTv.setText("寻找投资人");
        }

    }
}
